// @ts-nocheck
import request from "@/utils/fetch"

//用户登陆
export async function loginByTel(data:{
    password: string
    telephoneCode: string
}):Promise<LoginInfoRes>{
    return await request({
        url: '/qdjx/home/userLoginByPhoneAndPassword.do',
        method: 'post',
        data
    })
}

//获取验证码
export async function getCode(data:{
    telphoneCode:string
}):Promise<any>{
    return await request({
        url: '/qdjx/home/getSmsCode.do',
        method: 'post',
        data
    })
}

//更改密码
export async function updatePassword(data:{
    checkCode: string,
    oldPassword: string,
    password: string,
    telephoneCode: string
}){
    return await request({
        url: '/qdjx/home/updatePassword.do',
        method: 'post',
        data
    })
}

//更改密码
export async function unbind(){
    return await request({
        url: '/qdjx/home/updatePassword.do',
        method: 'post',
        data
    })
}


//获取用户信息
export async function getUserInfo(): Promise<UserInfoRes[]> {
    return await request<UserInfoRes[]>({
        url: '/qdjx/student/getPersonCenterInfo.do',
        method: 'get',
        params: {}
    })
}

//获取评价配置
export async function getAllAppraiseItem(params:{
    //1驾校评价项目 2教练评价项目
    type:'1'|'2'
}){
    return await request<AppraiseItemRes[]>({
        url: '/qdjx/student/getAllAppraiseItem.do',
        method: 'get',
        params
    })
}

//保存评价
export async function saveStudentAppraise(data:SaveAppraiseReq){
    return await request({
        url: '/qdjx/student/studentAppraise.do',
        method: 'post',
        data
    })
}
export interface SaveAppraiseReq{
    //评价id
    appraiseId:string
    appraiseItems:
        { appraiseItemId:string,score:string }[]
    //是否是驾校评价 1:是 0：不是
    isSchoolAppraise:'1' |'0'
}


export interface AppraiseItemRes{
    //评价项id
    appraiseId:string
    //评价项名称
    appraiseName:string
    //项目说明
    comment:string
    //1是否选项 2星级选项
    evalType:'1'|'2'
    //单项得分
    score:string
}


export interface UserInfoRes {

    subjectOneGrades: SubjectGrade[]
    subjectTwoGrades: SubjectGrade[]
    subjectThreeGrades: SubjectGrade[]
    subjectFourGrades: SubjectGrade[]
    [k: string]: any;

}

interface SubjectGrade {
    //考试日期
    examDate: string,
    //考试成绩
    grade: string,
    //考试结果
    result: string
}

interface LoginInfoRes{
    token:string
    [k: string]: any;
}